home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 11, No. 02 (1990-02)(MindCraft Publishing)(Side A).zip
/
Nibble Volume 11, No. 02 (1990-02)(MindCraft Publishing)(Side A).po
/
GS.ALARM.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
12KB
|
519 lines
********************************
* *
* GS.ALARM SOURCE CODE *
* *
* by Elwood J.C. Kureth *
* Copyright(c) 1990 *
* MindCraft Publ. Corp. *
* Concord, MA 01742 *
* *
********************************
*
*
*
* MERLIN 8/16 ASSEMBLER
*
*
*================== SECTION 0 ======================*
BELL = $FBDD ;monitor bell routine
COUT = $FDED ;monitor output routine
HOME = $FC58 ;monitor clear screen
STROBE = $C010 ;keyboard strobe
INBUFF = $200 ;input buffer use by GETLN2
TEFLAG = $3CE ;previous time/event flag
GETLN2 = $FD6F ;monitor input routine
VGCINT = $C023 ;VGC interrupt register
DOSWARM = $3D0 ;DOS warmstart vector
SCANINT = $C032 ;Scan-line interrupt reg
KEYBOARD = $C000 ;read keyboard
USERVECL = $3FE ;user interrupt vector-low
USERVECH = $3FF ;user interrupt vector-high
ORG $9001
LDA #$00 ;set HIMEM to $9000
STA $4C
LDA #$90
STA $4D
BEGIN JSR HOME
*================== SECTION 0a ===================*
LDA TEFLAG ;check flag to see if
CMP #"S" ;alarm has already been
BNE CLEAR ;set
RESET LDY #$00 ;tell user that he/she
:1 LDA RMSSG,Y ;has already set alarm
BEQ DISPLAY
JSR COUT
INY
BRA :1
DISPLAY LDY #$00 ;display current alarm
:1 LDA TEBUFF,Y ;time
JSR COUT
CPY #$07
BEQ ASK
INY
BRA :1
ASK LDY #$00 ;ask the user if he/she
:1 LDA RMSSG2,Y ;wants to remove the old
BEQ GETANS ;alarm and set a new one
JSR COUT
INY
BRA :1
GETANS JSR GETLN2
LDA INBUFF
CMP #"Y"
BEQ CLEAR
CMP #"y"
BEQ CLEAR
CMP #"N"
BEQ QUIT
CMP #"n"
BEQ QUIT
YorN1 LDY #$00 ;tell user to type only
:1 LDA CMSSG2,Y ;a 'Y' or 'N'
BEQ GETANS
JSR COUT
INY
BNE :1
QUIT JSR HOME ;no change to alarm -
JMP DOSWARM ;quit
*================== SECTION 1 ====================*
CLEAR JSR HOME
* Display time prompt message.
TPROMPT LDY #$00
:1 LDA TMSSG,Y ;print message
BEQ TIME ;done, go to user for input
JSR COUT
INY
BNE :1
*================== SECTION 2 ====================*
TIME JSR GETLN2 ;get time from user
LDA INBUFF ;is first character a
CMP #$91 ;CONTROL-Q?
BNE TIMCHK
JSR HOME ;yes - quit APPEAR
JMP DOSWARM
* Ensure the user is entering the time in the correct
* format and is using valid characters.
TIMCHK TXA
TAY
DEY
LDA INBUFF,Y
CMP #"M"
BEQ CHECKP
CMP #"m"
BNE ERRORTIM
LDA #"M"
STA INBUFF,Y
CHECKP DEY
LDA INBUFF,Y
CMP #"P"
BEQ CHECKSP
CMP #"p"
BNE NOTP
LDA #"P"
STA INBUFF,Y
BRA CHECKSP
NOTP CMP #"A"
BEQ CHECKSP
CMP #"a"
BNE ERRORTIM
LDA #"A"
STA INBUFF,Y
BRA CHECKSP
ERRORTIM JSR HOME
LDY #$00
:1 LDA ERROR,Y
BEQ TIME
JSR COUT
INY
BNE :1
CHECKSP DEY
LDA INBUFF,Y
CMP #" "
BNE ERRORTIM
BRA CHKMIN1
CLEAR2 BRA CLEAR
CHKMIN1 DEY
LDA INBUFF,Y
CMP #"0"
BMI ERRORTIM
CMP #":"
BPL ERRORTIM
CHKMIN2 DEY
LDA INBUFF,Y
CMP #"0"
BMI ERRORTIM
CMP #"6"
BPL ERRORTIM
CHKCOLON DEY
LDA INBUFF,Y
CMP #":"
BNE ERRORTIM
CPX #$08
BNE CHK07
CHK08 DEY
LDA INBUFF,Y
CMP #"0"
BMI ERRORTIM
CMP #"3"
BPL ERRORTIM
DEY
LDA INBUFF,Y
CMP #"1"
BNE ERRORTIM
BRA FULL8
CLEAR1 BRA CLEAR2
CHK07 DEY
LDA INBUFF,Y
CMP #"1"
BMI ERRORTIM
CMP #":"
BPL ERRORTIM
* Transfer GETLN2 buffer (INBUFF) contents to
* time/event buffer (TEBUFF).
ONLY7 LDA #" " ;put SPACE character at
STA TEBUFF ;start of buffer
DEX ;bring pointer back one
;byte to point at last
;character of time string-
;X now equals 6
LDY #$07
:1 LDA INBUFF,X
STA TEBUFF,Y
DEX
DEY
BEQ DONE2
BNE :1
FULL8 DEX ;X now equals 7
LDA INBUFF,X
STA TEBUFF,X
CPX #$00 ;beginning of buffer?
BEQ DONE2 ;yes - finished
BNE FULL8 ;no - get more
DONE2 ;finished section 2
*================== SECTION 2a ===================*
* Give user a chance to change his time.
CHANGE LDY #$00
:1 LDA CMSSG,Y ;print time ok? prompt mssg
BEQ CHNGTIME ;done-go to user for input
JSR COUT
INY
BNE :1
CHNGTIME JSR GETLN2
LDA INBUFF
CMP #"Y"
BEQ EPROMPT
CMP #"y"
BEQ EPROMPT
CMP #"N"
BEQ CLEAR1
CMP #"n"
BEQ CLEAR1
YorN2 LDY #$00 ;tell user to type only
:1 LDA CMSSG2,Y ;a 'Y' or 'N'
BEQ CHNGTIME
JSR COUT
INY
BNE :1
*================== SECTION 3 ====================*
* Display event message prompt.
CLEAR4 JSR HOME
EPROMPT LDY #$00
:1 LDA EMSSG,Y ;print event prompt mssg
BEQ EVENT ;done - go to user for input
JSR COUT
INY
BNE :1
*================== SECTION 4 ====================*
EVENT JSR GETLN2 ;get event from user
LDA INBUFF ;is first character a
CMP #$91 ;CONTROL-Q?
BNE XBUFF2
JSR HOME ;yes - quit APPEAR
JMP DOSWARM
* Place the event in the time/event buffer
* immediately after the time.
XBUFF2 LDX #$00
LDY #$08 ;point past end of time
;string in TEBUFF
:1 LDA INBUFF,X
STA TEBUFF,Y
CMP #$8D ;carriage return?
BEQ EPROMP2 ;yes - finished
INX
INY
BNE :1
*================== SECTION 4a ===================*
* Ask the user if the message is OK. Set a flag
* (SETFLAG) if the message is OK. SETFLAG will
* notify APPEAR that a time and an event have been
* entered and the current alarm has not yet been
* activated (gone off.)
EPROMP2 LDY #$00
:1 LDA EMSSG2,Y ;is message ok? prompt
BEQ GETANS2
JSR COUT
INY
BNE :1
GETANS2 JSR GETLN2
LDA INBUFF
CMP #"Y"
BEQ SETFLAG
CMP #"y"
BEQ SETFLAG
CMP #"N"
BEQ CLEAR4
CMP #"n"
BEQ CLEAR4
YorN3 LDY #$00 ;tell user to type only
:1 LDA CMSSG2,Y ;a 'Y' or 'N'
BEQ GETANS2
JSR COUT
INY
BNE :1
SETFLAG LDA #"S"
STA TEFLAG
JSR HOME
*================== SECTION 5 ===================*
* Set user interrupt vector to address of main
* routine (starting at MAIN), enable the 1-second
* timer interrupt (bit 2 - VGCINT), and jump to
* BASIC.
SETVEC LDA #$EE
STA USERVECL
LDA #$91
STA USERVECH
LDA VGCINT
ORA #%00000100
STA VGCINT
JMP DOSWARM
*================== SECTION 6 ====================*
* Save some registers by pushing them on the stack,
* place the processor in 16-bit mode and access the
* miscellaneous tool ReadTimeASCII, which returns the
* date and time as a string of characters.
MAIN PHP
PHB
PHA
PHX
PHY
CLC ;emulation to native
XCE ;e = 0 = native (enable)
REP $30 ;m & x = 0 (accumulator,
;memory locations, and
;index registers = 16 bits)
MTSTART LDX #$0203 ;misc. tools startup
JSL $E10000 ;entry point for toolbox
;routines
PEA ^DTBUFF ;pointer to input buffer
;(high word)
PEA DTBUFF ;low word
LDX #$0F03 ;ReadTimeASCII
JSL $E10000 ;put string in memory
MTSHUT LDX #$0303 ;misc. tools shutdown
JSL $E10000
SEC
XCE ;back to emulation (8 bits)
*================== SECTION 7 ====================*
* Compare the time/event buffer to the IIGS date/time
* buffer. When the times in both buffers match, buzz
* the alarm and display the event message.
COMPARE LDA TEBUFF+6 ;check for AM or PM.
CMP DTBUFF+18
BNE NOMATCH
OKAMPM LDX #$04 ;AM/PM match; now check
LDY #$0D ;the rest of the time.
GETMORE LDA TEBUFF,X
CMP DTBUFF,Y
BNE NOMATCH
DEX
DEY
CPY #$08 ;end of DTBUFF? If so, the
;times match. Fall through
;to ALLMATCH and alert the
;user.
BNE GETMORE
ALLMATCH LDA VGCINT ;turn off interrupt
AND #%11111011
STA VGCINT
LDY #$00
:1 LDA CRS,Y
BEQ PRINT
JSR COUT
INY
BRA :1
PRINT LDY #$08 ;point to start of event msg
:1 LDA TEBUFF,Y ;print event mssg.
JSR COUT
CMP #$8D
BEQ RINGBELL ;go ring bell
INY
BRA :1
* ----------------------------------------------- *
* Restore the registers by pulling from the stack,
* reset 1-second interrupt (bit 6 - SCANINT), and
* return from interrupt (RTI) to BASIC.
NOMATCH PLY
PLX
PLA
PLB
PLP
LDA SCANINT
AND #%10111111
STA SCANINT
RTI
* ----------------------------------------------- *
RINGBELL LDA #"N" ;first, remove the 'S'
STA TEFLAG ;from the flag location
;so APPEAR knows the alarm
;has been activated
JSR BELL
LDA KEYBOARD ;read keyboard
CMP #$80 ;was a key pressed?
BCC RINGBELL ;no - ring again
STA STROBE ;clear character from kybd
PLY ;restore registers
PLX
PLA
PLB
PLP
DONE7 RTI ;Event displayed. Back to
;BASIC
*============= messages and data storage ==========*
RMSSG ASC "YOU'VE SET AN ALARM FOR - ",8D,8D,00
RMSSG2 HEX 8D,8D
ASC "DO YOU WISH TO REMOVE THIS ALARM "
ASC "AND SET A NEW ONE? (Y or N) ",00
TMSSG ASC "ENSURE THAT IIGS CLOCK",8D
ASC "IS IN AM - PM FORMAT",8D,8D
ASC "Set Time (example - 8:30_PM",8D
ASC "CONTROL-Q and RETURN to Quit):",8D,8D
HEX 00
ERROR ASC "INVALID TIME ENTRY - REENTER:",8D
ASC "(example - 8:30_PM)",8D,00
EMSSG HEX 8D
ASC "Event or Appointment",8D
ASC "(Message limited to 160 characters"
ASC " -",8D
ASC "4 full screen lines in 40-column"
ASC " mode"8D
ASC "CONTROL-Q and RETURN to Quit):",8D,8D
HEX 00
EMSSG2 HEX 8D
ASC "Is Message OK? (Y or N) ",00
CMSSG ASC "Is time OK? (Y or N) ",00
CMSSG2 ASC "Type 'Y' or 'N' only ",00
CRS HEX 8D,8D,8D,8D,8D,8D,8D,00
DTBUFF DS 20 ;date and time buffer for
;ReadTimeASCII
TEBUFF ;time and event buffer